/******************************************************************************

    Simple Authentication and Authorisation System (SAAS)

    saas-test-username2uid.c

    Copyright (C) 2011  Josh Goes


    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.

    If you require a mailing address for this software, please send your
    mail to the following address:
        SAAS
        GPO Box 2973
        BRISBANE QLD 4001
        AUSTRALIA

******************************************************************************/


#include <stdio.h>
#include <stdlib.h>

#include "saas.h"



int main( int argc , char *argv[] )
{
	saas_t     inst;
	uint32_t   uid;
	char *username;
	uint16_t   ret;

	if ( argc != 2 )
	{
		printf( "usage: %s <uid>\n" , argv[0] );
		return 1;
	}

	printf( "calling saas_init()\n" );
	ret = saas_init( &inst , NULL , LOG_DEBUG , SAAS_LOG_STDOUT , 0 , NULL );
	if ( ret != SAAS_OP_SUCCESS )
	{
		printf( "ERROR whilst calling saas_init(): (%d) %s\n" , ret , saaserror( ret ) );
		return 1;
	}

	username = argv[1];

	printf( "Instance debugging data:\n" );
	saas_dump( &inst , " - " );

	printf( "launching username2uid request...\n" );
	ret = saas_username_to_uid( &inst , username , &uid );
	printf( "username2uid request returned: (%d) %s with uid %u\n" , ret , saaserror( ret ) , uid );

	return 0;

}


